$NG.AllReady(function (page, { useDataIndexChange, useUpdateRow,useValuesChange , useUpdateRows }) {
    const mstform = $NG.getCmpApi("p_form_risk_track")
    const user = $NG.getUser()
    $NG.updateState((updater)=>{
        updater.data.p_form_risk_track.setProps({
            u_feedback_dt:formatDate(new Date(), "yyyy-mm-dd")
        })
    })
    
    const useArr = [
        "p_form_risk_track.u_clf",
        "p_form_risk_track.u_gs",
        "p_form_risk_track.u_prc",
        "p_form_risk_track.u_cailiao",
    ]
    useArr.forEach(item=>{
        useValuesChange(({args})=>{
            $NG.updateState((updater)=>{
                updater.data.p_form_risk_track.setProps({
                    u_total:(mstform.getItem("u_clf").getValue() || 0)
                    +((mstform.getItem("u_gs").getValue()||0)*(mstform.getItem("u_prc").getValue()||0))
                    +(mstform.getItem("u_cailiao").getValue()||0)
                })
            })
        },item)
    })


    // 格式化日期
function formatDate(dateStr, outputFormat) {
    const date = new Date(dateStr);

    if (isNaN(date)) {
        return "无效的日期字符串";
    }

    const year = date.getFullYear();
    const month = String(date.getMonth() + 1).padStart(2, '0');
    const day = String(date.getDate()).padStart(2, '0');
    const hours = String(date.getHours()).padStart(2, '0');
    const minutes = String(date.getMinutes()).padStart(2, '0');

    let formattedDate;

    switch (outputFormat) {
        case "yyyy-mm-dd":
            formattedDate = `${year}-${month}-${day}`;
            break;
        case "yyyy-mm-dd HH:mm":
            formattedDate = `${year}-${month}-${day} ${hours}:${minutes}`;
            break;
        // 可以根据需要继续添加其他格式的处理逻辑
        default:
            formattedDate = "不支持的输出格式";
    }

    return formattedDate;
}
});

